﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace MyDelegate
{

    public delegate void NoParaNoReturnOutClass();
    public class MyDelegate
    {
        private delegate void NoParaNoReturn();
        private delegate void WithParaNoReturn(string name, int id, DateTime now);
        private delegate int NoParaWithReturn();
        private delegate MyDelegate WithParaWithReturn(string name);


        public static void Show()
        {
            #region lesson 1
            //var method = new NoParaNoReturn(ShowSomething);
            //method.Invoke();
            //method();

            #endregion

            //#region lesson 2
            //NoParaWithReturn noParaWithReturnMethod = new NoParaWithReturn(GetSomething);
        
            //// var intRst = noParaWithReturnMethod.Invoke();

            //noParaWithReturnMethod += GetSomething;
            //noParaWithReturnMethod += GetSomething;
            //noParaWithReturnMethod += GetSomething;
            //noParaWithReturnMethod += GetSomething;
          
            //Console.WriteLine("noParaWithReturnMethod.Invoke结果是:{0}", noParaWithReturnMethod.Invoke());
            ////  Console.WriteLine("noParaWithReturnMethod():{0}", noParaWithReturnMethod());
            //#endregion

        }
        private static void ShowSomething()
        {
            Console.Write("这里是ShowSomething");
        }

        private static int GetSomething()
        {
            Console.Write("这里是GetSomething");
            Thread.Sleep(1200);
            return 11;// DateTime.Now.Second;
        }
    }
}
